import geo
import walk
import pandas as pd


def direction_bus(key, start_address, end_address,city):
    """    """
    start = geo.geocode(key, start_address)['geocodes'][0]['location']
    end = geo.geocode(key, end_address)['geocodes'][0]['location']
    results = walk.bus(key, start, end, city)
    df = pd.json_normalize(results['route']['transits'][0]['segments'][0]['bus']['buslines'])
    return df


def total_bus(df):
    """    """
    distance = df['distance'].to_list()
    sum_num = 0
    for i in distance:
        sum_num += int(i)
    return sum_num


def total_bus_time(df):
    """    """
    duration = df['duration'].to_list()
    sum_num = 0
    for i in duration:
        sum_num += int(i)
    return sum_num // 60